//
//  UIImage+ChangeSize.swift
//  图片浏览器
//
//  Created by Jacky Sun on 16/6/1.
//  Copyright © 2016年 syf. All rights reserved.
//

import UIKit

extension UIImage{
    
    func returnNewImage(width: CGFloat) ->UIImage{
        
        let height = width * size.height / size.width
        let newSize = CGSize(width: width, height: height)
        
        // 绘制一张新的照片
        UIGraphicsBeginImageContext(newSize)
        drawInRect(CGRect(origin: CGPointZero, size: newSize))
        let newIMg = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        
        return newIMg
    }
}
